﻿@using News.Models.Database;
@using News.Models;
@{
	var category = ViewData["ALL_Categorys"] as List<Category>;
	int _NOW_CategoryID_ = Public.NOW_CategoryID;
	//转换类型
	var news = ViewData["News"] as List<News>;
	//共多少行（页）->row
	var row = 0;
	if (news.Count % 12 == 0)
	{
		row = news.Count / 12;
	}
	else
	{
		row = (news.Count / 12) + 1;
	}


	//<div id="main">
	<ul id="main_ul">


		@{
			var list = news.Skip(((int)ViewData["NOW_Page"] - 1) * 12).Take(12).ToList();
			foreach (var item in list)
			{
				<li>
					<a href="detail.html?newsID=@item.NewsId">
						<img src="@item.NewsPic">
						<p>@item.NewsTitle</p>
						<p>
							@item.NewsContent
						</p>
						<p>发布时间:@item.NewsTime</p>
						<p>文章来源:@item.NewsSource</p>
					</a>
				</li>
			}
		}


		@*<li>
	<a href="detail.html">
	<img src="http://cms-bucket.ws.126.net/2021/0609/d7e3f7bbp00quf9r60017c0009c0070c.png?imageView&thumbnail=200y140">
	<p>360数科发布碳中和计划，承诺2030年实现碳达峰</p>
	<p>
	6月9日消息，为积极响应国家“3060”碳中和目标，360数科于近日发布《2021碳中和计划》（下称《计划》），承诺自今年起逐步实现运营排放（范围一、范围二）的碳中和，2030年实现碳达峰；2060年前实现其自身业务及其客户活动的温室气体
	</p>
	<p>发布时间:2021-06-09 14:52</p>
	<p>文章来源:网易互联网</p>
	</a>
	</li>*@




	</ul>
			//</div>
	<div class="paging">
		<ul class="pagination">

			@{
				bool _checked = false;
				for (int i = 1; i <= row; i++)
				{


					if ((int)ViewData["NOW_Page"] != 1 && _checked == false)
					{
						int k = (int)ViewData["NOW_Page"] - 1;
						<li><a class="FANYE" href="/index.html?now_categoryid=@_NOW_CategoryID_&now_page=@k">«</a></li>
						_checked = true;
					}
					else if (_checked == false)
					{
						<li style="pointer-events: none;"><a class="FANYE">«</a></li>
						_checked = true;
					}

					if ((int)ViewData["NOW_Page"] == i)
					{
						<li><a href="/index.html?now_categoryid=@_NOW_CategoryID_&now_page=@i" class="active">@i</a></li>
					}
					else
					{
						@* @item.CateName  分类对象.分类名字  *@
						<li><a href="/index.html?now_categoryid=@_NOW_CategoryID_&now_page=@i">@i</a></li>
					}

					if (i == row)
					{
						if ((int)ViewData["NOW_Page"] == row && _checked == true)
						{
							<li style="pointer-events: none;"><a href="javascript:void(0)" class="FANYE">»</a></li>
						}
						else
						{
							int k = (int)ViewData["NOW_Page"] + 1;
							<li><a href="/index.html?now_categoryid=@_NOW_CategoryID_&now_page=@k" class="FANYE">»</a></li>
						}
					}
				}
			}

			@*<li><a href="javascript:void(0)">«</a></li>
		<li><a class="active" href="javascript:void(0)">1</a></li>
		<li><a href="javascript:void(0)">2</a></li>
		<li><a href="javascript:void(0)">3</a></li>
		<li><a href="javascript:void(0)">4</a></li>
		<li><a href="javascript:void(0)">5</a></li>
		<li><a href="javascript:void(0)">6</a></li>
		<li><a href="javascript:void(0)">7</a></li>
		<li><a href="javascript:void(0)">»</a></li>*@
		</ul>
		@*}*@
	</div>
}

@*<div id="main">
		<ul id="main_ul">
		<li>
		<a href="detail.html">
		<img src="http://cms-bucket.ws.126.net/2021/0609/d7e3f7bbp00quf9r60017c0009c0070c.png?imageView&thumbnail=200y140">
		<p>360数科发布碳中和计划，承诺2030年实现碳达峰</p>
		<p>
		6月9日消息，为积极响应国家“3060”碳中和目标，360数科于近日发布《2021碳中和计划》（下称《计划》），承诺自今年起逐步实现运营排放（范围一、范围二）的碳中和，2030年实现碳达峰；2060年前实现其自身业务及其客户活动的温室气体
		</p>
		<p>发布时间:2021-06-09 14:52</p>
		<p>文章来源:网易互联网</p>
		</a>
		</li>
		</ul>
		</div>
		<div class="paging">
		<ul class="pagination">
		<li><a href="javascript:void(0)">«</a></li>
		<li><a class="active" href="javascript:void(0)">1</a></li>
		<li><a href="javascript:void(0)">2</a></li>
		<li><a href="javascript:void(0)">3</a></li>
		<li><a href="javascript:void(0)">4</a></li>
		<li><a href="javascript:void(0)">5</a></li>
		<li><a href="javascript:void(0)">6</a></li>
		<li><a href="javascript:void(0)">7</a></li>
		<li><a href="javascript:void(0)">»</a></li>
		</ul>
		</div>*@

@section script{
	<script src="https://code.jquery.com/jquery-3.6.0.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		$(function () {
			$("#search").on("click",
				function () {
					var search_content = $("#content").val();
					if (search_content == "") {
						return;
					}
					//                            类里面的字段：post值
					$.post('/home/search', { S_Content: search_content }, function (data, success) {
						console.log('服务器返回结果：' + data);
						if (data == "查询成功") {
							window.location.href = "index.html?now_categoryid=@_NOW_CategoryID_&search_con=" + search_content;
						}
					});

				});
		})
	</script>
	}
